package customer

import (
	"counter-help/admin/server/global"
    "counter-help/admin/server/model/common/response"
    "counter-help/admin/server/model/customer"
    customerReq "counter-help/admin/server/model/customer/request"
    "github.com/gin-gonic/gin"
    "go.uber.org/zap"
)

type CusReminderApi struct {}

// CreateCusReminder 创建cusReminder表
// @Tags CusReminder
// @Summary 创建cusReminder表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body customer.CusReminder true "创建cusReminder表"
// @Success 200 {object} response.Response{msg=string} "创建成功"
// @Router /cusReminder/createCusReminder [post]
func (cusReminderApi *CusReminderApi) CreateCusReminder(c *gin.Context) {
	var cusReminder customer.CusReminder
	err := c.ShouldBindJSON(&cusReminder)
	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	err = cusReminderService.CreateCusReminder(&cusReminder)
	if err != nil {
        global.GVA_LOG.Error("创建失败!", zap.Error(err))
		response.FailWithMessage("创建失败:" + err.Error(), c)
		return
	}
    response.OkWithMessage("创建成功", c)
}

// DeleteCusReminder 删除cusReminder表
// @Tags CusReminder
// @Summary 删除cusReminder表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body customer.CusReminder true "删除cusReminder表"
// @Success 200 {object} response.Response{msg=string} "删除成功"
// @Router /cusReminder/deleteCusReminder [delete]
func (cusReminderApi *CusReminderApi) DeleteCusReminder(c *gin.Context) {
	ID := c.Query("ID")
	err := cusReminderService.DeleteCusReminder(ID)
	if err != nil {
        global.GVA_LOG.Error("删除失败!", zap.Error(err))
		response.FailWithMessage("删除失败:" + err.Error(), c)
		return
	}
	response.OkWithMessage("删除成功", c)
}

// DeleteCusReminderByIds 批量删除cusReminder表
// @Tags CusReminder
// @Summary 批量删除cusReminder表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Success 200 {object} response.Response{msg=string} "批量删除成功"
// @Router /cusReminder/deleteCusReminderByIds [delete]
func (cusReminderApi *CusReminderApi) DeleteCusReminderByIds(c *gin.Context) {
	IDs := c.QueryArray("IDs[]")
	err := cusReminderService.DeleteCusReminderByIds(IDs)
	if err != nil {
        global.GVA_LOG.Error("批量删除失败!", zap.Error(err))
		response.FailWithMessage("批量删除失败:" + err.Error(), c)
		return
	}
	response.OkWithMessage("批量删除成功", c)
}

// UpdateCusReminder 更新cusReminder表
// @Tags CusReminder
// @Summary 更新cusReminder表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body customer.CusReminder true "更新cusReminder表"
// @Success 200 {object} response.Response{msg=string} "更新成功"
// @Router /cusReminder/updateCusReminder [put]
func (cusReminderApi *CusReminderApi) UpdateCusReminder(c *gin.Context) {
	var cusReminder customer.CusReminder
	err := c.ShouldBindJSON(&cusReminder)
	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	err = cusReminderService.UpdateCusReminder(cusReminder)
	if err != nil {
        global.GVA_LOG.Error("更新失败!", zap.Error(err))
		response.FailWithMessage("更新失败:" + err.Error(), c)
		return
	}
	response.OkWithMessage("更新成功", c)
}

// FindCusReminder 用id查询cusReminder表
// @Tags CusReminder
// @Summary 用id查询cusReminder表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data query customer.CusReminder true "用id查询cusReminder表"
// @Success 200 {object} response.Response{data=customer.CusReminder,msg=string} "查询成功"
// @Router /cusReminder/findCusReminder [get]
func (cusReminderApi *CusReminderApi) FindCusReminder(c *gin.Context) {
	ID := c.Query("ID")
	recusReminder, err := cusReminderService.GetCusReminder(ID)
	if err != nil {
        global.GVA_LOG.Error("查询失败!", zap.Error(err))
		response.FailWithMessage("查询失败:" + err.Error(), c)
		return
	}
	response.OkWithData(recusReminder, c)
}

// GetCusReminderList 分页获取cusReminder表列表
// @Tags CusReminder
// @Summary 分页获取cusReminder表列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data query customerReq.CusReminderSearch true "分页获取cusReminder表列表"
// @Success 200 {object} response.Response{data=response.PageResult,msg=string} "获取成功"
// @Router /cusReminder/getCusReminderList [get]
func (cusReminderApi *CusReminderApi) GetCusReminderList(c *gin.Context) {
	var pageInfo customerReq.CusReminderSearch
	err := c.ShouldBindQuery(&pageInfo)
	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	list, total, err := cusReminderService.GetCusReminderInfoList(pageInfo)
	if err != nil {
	    global.GVA_LOG.Error("获取失败!", zap.Error(err))
        response.FailWithMessage("获取失败:" + err.Error(), c)
        return
    }
    response.OkWithDetailed(response.PageResult{
        List:     list,
        Total:    total,
        Page:     pageInfo.Page,
        PageSize: pageInfo.PageSize,
    }, "获取成功", c)
}

// GetCusReminderPublic 不需要鉴权的cusReminder表接口
// @Tags CusReminder
// @Summary 不需要鉴权的cusReminder表接口
// @accept application/json
// @Produce application/json
// @Param data query customerReq.CusReminderSearch true "分页获取cusReminder表列表"
// @Success 200 {object} response.Response{data=object,msg=string} "获取成功"
// @Router /cusReminder/getCusReminderPublic [get]
func (cusReminderApi *CusReminderApi) GetCusReminderPublic(c *gin.Context) {
    // 此接口不需要鉴权
    // 示例为返回了一个固定的消息接口，一般本接口用于C端服务，需要自己实现业务逻辑
    response.OkWithDetailed(gin.H{
       "info": "不需要鉴权的cusReminder表接口信息",
    }, "获取成功", c)
}
